<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
  </head>
  <body>
    <label>sessionStorageName:</label>
    <input type="text" id="sessionName" /><br />
    <label>sessionStorageValue:</label>
    <input type="text" id="sessionValue" /><br />
    <button onclick="setSessionStorage()">设置sessionStorage</button><br />
    <button onclick="removeSessionStorage()">移除sessionStorage</button><br />
    <label>localStorageName:</label> <input type="text" id="localName" /><br />
    <label>localStorageValue:</label>
    <input type="text" id="localValue" /><br />
    <button onclick="setLocalStorage()">设置localStorage</button><br />
    <button onclick="removeLocalStorage()">移除localStorage</button><br />
    <script>
      function setSessionStorage() {
        var name = document.getElementById("sessionName").value;
        var value = document.getElementById("sessionValue").value;
        sessionStorage.setItem(name, value);
      }
      function setLocalStorage() {
        var name = document.getElementById("localName").value;
        var value = document.getElementById("localValue").value;
        localStorage.setItem(name, value);
      }
      function removeSessionStorage(){
        var name = document.getElementById("sessionName").value;
        sessionStorage.removeItem(name)
      }
      function removeLocalStorage(){
        var name = document.getElementById("localName").value;
        localStorage.removeItem(name)
      }
    </script>
  </body>
</html>
